package com.example.mainstream.fragment;

import android.content.Intent;

import androidx.recyclerview.widget.LinearLayoutManager;

import com.example.shopapp.R;
import com.example.shopapp.adapter.IUserListener;
import com.example.shopapp.adapter.UserAdapter;
import com.example.shopapp.bean.User;
import com.example.shopapp.database.UserDBUtils;
import com.example.shopapp.databinding.FragmentUserBinding;
import com.example.shopapp.ui.ChatActivity;
import com.example.shopapp.widget.MyItemDecoration;

import cn.project.base.baseui.BaseNormalFragment;


public class MUserFragment extends BaseNormalFragment<FragmentUserBinding> implements IUserListener {


    UserAdapter userAdapter;
    @Override
    protected int getLayoutId() {
        return  R.layout.fragment_user;
    }

    @Override
    protected void initData() {
        userAdapter = new UserAdapter(getActivity(),this);
        mBinding.rlAction.setLayoutManager(new LinearLayoutManager(getActivity()));
        mBinding.rlAction.addItemDecoration(new MyItemDecoration(10));
        mBinding.rlAction.setAdapter(userAdapter);
        userAdapter.setNewData(UserDBUtils.getInstance(getActivity()).getUserList());
        userAdapter.notifyDataSetChanged();
    }




    @Override
    public void UserClick(User user) {
        Intent intent = new Intent(getActivity(), ChatActivity.class);
        intent.putExtra("data", user);
        startActivity(intent);
    }



}
